/*
*WriteJava.fx
*
*Created on Apr 4, 2011, 02:38:22 AM
*/

package mythesis.controller;
import java.io.*;
import java.lang.*;

public function write(code:String, fileNumber:Number):String
{
    try{
	    //var fstream:java.io.FileWriter = new FileWriter("CustomAI{fileNumber as Integer}.java");
	    var f = new File("");
	    var root = f.getAbsolutePath();
	    root = root.substring(0, root.length()-16);
	    var aidir = "{root}Cluedo\\Cluedo\\AI\\";
	    println("Writing to {aidir}CustomAI{fileNumber as Integer}.java");
	    var fstream:java.io.FileWriter = new FileWriter("{aidir}CustomAI{fileNumber as Integer}.java");
	    var out:BufferedWriter = new BufferedWriter(fstream);
	    out.write(code);
	    out.close();
	    return "Successfully saved as CustomAI{fileNumber as Integer}.java!";
    }
    catch(e:Exception)
    {
		println(" Error in WriteJava.write(): {e}");
		return "Error in writing to CustomAI{fileNumber as Integer}.xml, please check console output for details.";       
    }
}

public class WriteJava {

};
